<template>
  <el-container class="mainContent">
    <el-row>
      <el-col class="title">家庭医生签约统计表</el-col>
    </el-row>
    <el-row class="search-layer">
      <el-col>
        <el-form :inline="true" :model="formSearch" class="demo-form-inline">
          <el-form-item label="签约团队:">
            <el-input v-model="formSearch.groupName" placeholder="请输入用户"></el-input>
          </el-form-item>
          <el-form-item label="签约时间:">
            <el-date-picker
              v-model="formSearch.time"
              type="daterange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              format="yyyy 年 MM 月 dd 日"
              value-format="yyyy-MM-dd"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="searchGroup">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="info" icon="el-icon-document-add" @click="toExecl">导出</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-table :data="groupData" stripe style="width: 100%">
        <el-table-column prop="contractTeam" label="签约团队" width="180"></el-table-column>
        <el-table-column prop="contractNumber" label="签约数量" width="100"></el-table-column>
        <el-table-column prop="children" label="0-6岁儿童" width="150"></el-table-column>
        <el-table-column prop="elderly" label="老年人" width="150"></el-table-column>
        <el-table-column prop="maternal" label="孕产妇" width="150"></el-table-column>
        <el-table-column prop="hypertension" label="高血压" width="150"></el-table-column>
        <el-table-column prop="diabetes" label="糖尿病" width="150"></el-table-column>
        <el-table-column prop="disorder" label="严重精神障碍" width="150"></el-table-column>
        <el-table-column prop="disabilitie" label="残疾人" width="150"></el-table-column>
        <el-table-column prop="healthyPeople" label="健康居民" width="150"></el-table-column>
        <el-table-column prop="contactDate" label="签约时间"></el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="10"
        layout="total, sizes, prev, pager, next, jumper"
        :total="count"
        class="pagination"
      ></el-pagination>
    </el-row>
  </el-container>
</template>
<script>
export default {
  name: "StatisticalTable",
  data() {
    return {
      formSearch: {
        groupName: "",
        time: [],
      },
      groupData: [],
      currentPage: 1,
      count: 0,
      num: 10,
    };
  },
  methods: {
    getData() {
      this.axios({
        url: "/getGroupData",
        params: {
          page: this.currentPage,
          num: this.num,
          groupName: this.formSearch.groupName,
          time: this.formSearch.time,
        },
        methods: "get",
      })
        .then((result) => {
          console.log(result);
          if (result.data.code === 200) {
            this.groupData = result.data.data;
            this.count = result.data.count;
          } else {
            this.$message.error("请求数据失败");
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    onSubmit() {
      console.log("submit!");
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.num = val;
      this.getData();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getData();
      // console.log(`当前页: ${val}`);
    },
    searchGroup() {
      console.log(this.formSearch.groupName);
      this.getData();
      console.log(this.formSearch.time);
    },
    toExecl() {},
     goBack() {
        console.log('go back');
      }
  },
  mounted() {
    this.getData();
  },
};
</script>
<style lang="less" scoped>
.form-inline {
  width: 100%;
  height: 300px;
  text-align: left;
}
.mainContent {
  width: 100%;
  flex-direction: column;
  text-align: left;
}
.search-layer {
  width: 100%;
}
.pagination {
  margin-top: 50px;
  text-align: center;
}
.title{
  margin-bottom: 30px;
  font-size: 20px;
  font-weight:600;
}
</style>